<template>
    <div class="box">
        <div class="box-hd">
            <div class="title-wrap">
                <div class="title">详细信息</div>
            </div>
        </div>
        <div class="box-bd">
            <div class="profile" v-if="user">
                <div class="avatar">
                    <img class="img" :src="user.bigusericon" alt="" v-if="user.bigusericon">
                    <img class="img" src="../../assets/person_icon.jpg" alt="" v-else>
                </div>
                <div class="remark" v-if="user.remark != ''">{{user.remark}}</div>
                <div class="nickname">昵称：{{user.nickname}}</div>
                <div class="action">
                    <el-button class="custom-btn" type="primary" @click="this.chooseFriend">发送消息</el-button>
                </div>
            </div>
            <div class="none" v-else>
                <img class="img img2" src="../../assets/no_friend.png" v-if="!friendList || friendList.length == 0">
                <img class="img" src="../../assets/no_message.png" v-else>
                <div class="text">{{ !friendList || friendList.length == 0 ? '暂无联系人' : '未选择用户' }}</div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    computed: {
        user() {
            return this.$store.state.base.currentUser
        },
        friendList() {
            return this.$store.state.base.friendList
        }
    },
    methods: {
        chooseFriend() {
            let params = {
                id: this.user.id,
                icon: this.user.usericon,
                name: this.user.remark !== '' ? this.user.remark : this.user.nickname,
                time: '',
                count: 0,
                msgType: 11,
                msgData: [],
                mute: this.user.mute
            }

            let inputObj = {
                content: '',
                atUserList: [],
                type: 'friend',
                id: this.user.id
            }
            this.$store.dispatch('insertChatInput', inputObj)
            this.$store.dispatch('createChat', params)
            this.$router.push({ path: '/message' })
        }
    }
}
</script>
